//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.t3go.t3_map.views;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Shader;
import android.graphics.Shader.TileMode;
import android.text.TextPaint;
import android.util.AttributeSet;

import androidx.appcompat.widget.AppCompatTextView;

import java.util.Arrays;

/**
 * 复制高德的StrokeTextView，增加setStrokeJoin(Paint.Join.ROUND)设置圆角
 */
public class T3StrokeTextView extends AppCompatTextView {
    private int[] a;
    private int b;
    private int c = -16777216;
    private LinearGradient d;
    private boolean e;
    private int f;
    private TextPaint g;
    private int h;
    private boolean isBold = true;

    public T3StrokeTextView(Context var1) {
        super(var1);
        this.a(var1, (AttributeSet) null);
    }

    public T3StrokeTextView(Context var1, AttributeSet var2) {
        super(var1, var2);
        this.a(var1, var2);
    }

    public T3StrokeTextView(Context var1, AttributeSet var2, int var3) {
        super(var1, var2, var3);
        this.a(var1, var2);
    }

    private void a(Context var1, AttributeSet var2) {
        this.g = this.getPaint();
        if (var2 != null) {
            this.c = -16777216;
            this.b = 0;
            this.h = 0;
            this.setStrokeColor(this.c);
            this.setStrokeWidth(this.b);
            this.setGradientOrientation(this.h);
        }

    }

    public void setGradientOrientation(int var1) {
        if (this.h != var1) {
            this.h = var1;
            this.e = true;
            this.invalidate();
        }

    }

    public void setGradientColor(int[] var1) {
        if (!Arrays.equals(var1, this.a)) {
            this.a = var1;
            this.e = true;
            this.invalidate();
        }

    }

    public void setStrokeColor(int var1) {
        if (this.c != var1) {
            this.c = var1;
            this.invalidate();
        }

    }

    public void setBold(boolean isBold) {
        if (this.isBold != isBold) {
            this.isBold = isBold;
            this.invalidate();
        }

    }

    protected void onDraw(Canvas var1) {
        if (this.b > 0) {
            this.f = this.getCurrentTextColor();
            this.g.setStrokeWidth((float) this.b);
            this.g.setFakeBoldText(this.isBold);
            this.g.setShadowLayer((float) this.b, 0.0F, 0.0F, 0);
            this.g.setStyle(Style.STROKE);
            this.g.setColor(this.c);
            this.setTextColor(this.c);
            this.g.setShader((Shader) null);
            this.g.setStrokeJoin(Paint.Join.ROUND);
            super.onDraw(var1);
            this.g.setStyle(Style.FILL);
            if (this.e) {
                if (this.a != null) {
                    this.d = this.a();
                }

                this.e = false;
            }

            if (this.d != null) {
                this.g.setShader(this.d);
                this.g.setColor(-1);
            } else {
                this.g.setColor(this.f);
            }

            this.setTextColor(this.f);
            this.g.setStrokeWidth(0.0F);
            this.g.setShadowLayer(0.0F, 0.0F, 0.0F, 0);
            super.onDraw(var1);
        } else {
            super.onDraw(var1);
        }

    }

    public void setStrokeWidth(int var1) {
        this.b = var1;
        this.invalidate();
    }

    private LinearGradient a() {
        LinearGradient var1;
        if (this.h == 0) {
            var1 = new LinearGradient(0.0F, 0.0F, (float) this.getWidth(), 0.0F, this.a, (float[]) null, TileMode.CLAMP);
        } else {
            var1 = new LinearGradient(0.0F, 0.0F, 0.0F, (float) this.getHeight(), this.a, (float[]) null, TileMode.CLAMP);
        }

        return var1;
    }
}
